package com.loong.data.controller.backend;

import com.loong.common.mvc.BaseBackendController;
import com.loong.common.param.BaseIdParam;
import com.loong.common.rest.Result;
import com.loong.common.validator.group.CommonValidate;
import com.loong.data.common.backend.param.PageParam;
import com.loong.data.common.backend.param.ShopQueryParam;
import com.loong.data.handler.ShopHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description: 处理后台有关店铺请求的controller
 * @Author: 刘群
 * @Date: 2020/11/11 11:59
 */
@Slf4j
@RestController
@RequestMapping("manage/data/shop")
public class ShopController extends BaseBackendController {

    @Resource
    private ShopHandler shopHandler;

    /**
     * 根据店铺id搜索店铺
     * @param idParam 店铺id封装的参数
     * @return 响应的结果
     */
    @PostMapping("findById")
    public Result findShopModelById(@Validated({CommonValidate.class})BaseIdParam idParam){
        return handlerExecutor.execute(() -> shopHandler.findShopModelById(idParam.getId()));
    }

    /**
     * 多条件分页查询店铺
     * @param shopParam 店铺查询参数
     * @param pageParam 分页参数
     * @return 响应的结果
     */
    @PostMapping("findShopList")
    public Result pageQueryShopModel(ShopQueryParam shopParam,PageParam pageParam){
        return handlerExecutor.execute(() -> shopHandler.pageQueryShopModel(shopParam,pageParam));
    }


}
